package com.joey.firstDemo.test;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import com.joey.firstDemo.userService.userService;

public class BeanFactory {
    public static void main(String[] args) {

        //创建bean工厂
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        //将读取器与bean工厂绑定
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);

        //读取配置文件
        reader.loadBeanDefinitions("userServiceConfig.xml");

        //通过id获取bean工厂生成的对象
        userService  us = (userService) beanFactory.getBean("userService");
        System.out.println(us);
    }
}
